#pragma once

class CVector
{
public:
	double x;
	double y;
	double z;

	CVector(double _x,double _y,double _z){x=_x;y=_y;z=_z;};
	CVector(){x=0.0;y=0.0;z=0.0;};
	void Normalize();
	double Distance(const CVector& Vect2) const;
	double DotProduct(const CVector& Vect2) const;
	CVector CrossProduct(const CVector& Vect2) const;
	double FastInvSqrt(double x)
	{
		double xhalf = 0.5f*x;
		int i = *(int*)&x;
		i = 0x5f3759df - (i>>1);
		x = *(double*)&i;
		x = x*(1.5f - xhalf*x*x);
		x = x*(1.5f - xhalf*x*x);
// 		x = x*(1.5f - xhalf*x*x);
// 		x = x*(1.5f - xhalf*x*x);
		return x;
	}

	
	CVector operator+( const CVector &rhs ) const{
		return CVector( x+rhs.x, y+rhs.y, z+rhs.z);
	}

	CVector operator-( const CVector &rhs ) const{
		return CVector( x-rhs.x, y-rhs.y, z-rhs.z);
	}

	CVector operator+=( const CVector &rhs ){
		return CVector( x+=rhs.x, y+=rhs.y, z+=rhs.z);
	}

	CVector operator-=( const CVector &rhs ){
		return CVector( x-=rhs.x, y-=rhs.y, z-=rhs.z);
	}

	CVector operator*( const double &rhs ) const{
		return CVector( x*rhs, y*rhs, z*rhs);
	}

	CVector operator/( const double &rhs ) const{
		return CVector( x/rhs, y/rhs, z/rhs);
	}

	CVector operator*=( const double &rhs ){
		return CVector( x*=rhs, y*=rhs, z*=rhs);
	}

	CVector operator/=( const double &rhs ){
		return CVector( x/=rhs, y/=rhs, z/=rhs);
	}

	bool operator!=(const CVector rhs) const
	{
		if(y!=rhs.x)
			return true;
		if(z!=rhs.y)
			return true;
		if(x!=rhs.z)
			return true;
		return false;
	}
	bool operator==(const CVector rhs) const
	{
		if(y!=rhs.x)
			return false;
		if(z!=rhs.y)
			return false;
		if(x!=rhs.z)
			return false;
		return true;
	}
};
